#!/usr/bin/env python
#coding=utf-8
from Applications.libs.utils import reluesInfo,utils
from Applications.models.AdminModel import adminModel
#from .AdminMenuService import adminMenusServer


class adminService(object):

    @classmethod
    def admin_login(cls,username,passwd):
        passwd = utils.Md5(passwd)
        admininfo = adminModel.check_admin(username,passwd)
        if admininfo is None:
            return reluesInfo(msg='对不起，您输入的账号或密码错误！'),None,None
        
        if admininfo.admin_del>0:
            return reluesInfo(msg='对不起，账户已被禁用，请联系管理员！'),None ,None

        #admin_menu = adminMenusServer.get_menus() #根据权限获取菜单

        admin_menu = None

        return reluesInfo(status=1),admininfo,admin_menu


    @classmethod
    def admin_list(cls):
        list = adminModel.get_admin_all()
        return list
